package
{
	import com.website.control.MainEntry;
	import com.website.ui.LoadProcessBar;
	
	import flash.display.Loader;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.ProgressEvent;
	import flash.net.URLRequest;
	
	[SWF(width=999, height = 774, frameRate = 30,backgroundColor="#FFFFFF")]
	public class WebSiteLoader extends Sprite
	{
		private var _rootUrl:String = "http://fly/";
		private var _loader:Loader;
		private var _loaderProcessBar:LoadProcessBar;
		public function WebSiteLoader()
		{
			addEventListener(Event.ADDED_TO_STAGE, onAddToStage);
//			addEventListener(Event.RESIZE,onResize);
		}

		private function onAddToStage(event:Event):void
		{
			darwBg();
			loadMain();
			MainEntry.setup(this);
		}
		
		
		
		private function darwBg():void
		{
//			graphics.drawRect(0,0,1000,560);
		}
		
		private function loadMain():void
		{
			_loader = new Loader();
			_loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProcess);
			_loader.contentLoaderInfo.addEventListener(Event.COMPLETE ,onLoadComplete);
//			_loader.load(new URLRequest(_rootUrl + "uerlParamsTest.swf"));
		}

		private function onProcess(event:ProgressEvent):void
		{
			if(_loaderProcessBar == null)
			{
//				_loaderProcessBar = new LoadProcessBar();
//				addChild(_loaderProcessBar);
//				_loaderProcessBar.x = (width - _loaderProcessBar.width) / 2;
//				_loaderProcessBar.y = (height - _loaderProcessBar.height) / 2;
			}
//			_loaderProcessBar.setProcess(event.bytesTotal, event.bytesLoaded);
		}
		
		private function onLoadComplete(event:Event):void
		{
			MainEntry.setup(this);
		}
	}
}